package usefunction;

import java.math.BigInteger;
import java.util.List;
import java.util.function.Function;
import java.util.function.IntBinaryOperator;
import java.util.function.IntPredicate;
import java.util.function.Supplier;

/**
 * @author: fqtang
 * @date: 2024/10/07/20:52
 * @description: 描述
 */
public class CategoryTest {

	static class Student {
		String name;
		int age;

		public Student() {
		}

		public Student(String name,int age) {
			this.name = name;
			this.age = age;
		}
		public String getName() {
			return name;
		}

		public void setName(String name) {
			this.name = name;
		}

		public int getAge() {
			return age;
		}

		public void setAge(int age) {
			this.age = age;
		}
	}

	public static void main(String[] args) {
		/*Type1 type1 = a -> (a & 1) == 0;
		Type1 type2 = a -> BigInteger.valueOf(a)
			.isProbablePrime(100);
		Type2 type3 = (a, b, c) -> a + b + c;
		Type3 type4 = (a, b) -> a + b;
		Type3 type5 = (a, b) -> a - b;
		Type4<Student> obj5 = () -> new Student();
		Type4<List<Student>> obj6 = () -> List.of(new Student());
		Type0<String, Student> obj7 = s -> s.getName();
		//通过上下文推导出s为Student
		Type0<Integer, Student> obj8 = s -> s.getAge();
*/

		IntPredicate type1 = a -> (a & 1) == 0;
		IntPredicate type2 = a -> BigInteger.valueOf(a)
			.isProbablePrime(100);
		IntTernaryOperator type3 = (a, b, c) -> a + b + c;
		IntBinaryOperator type4 = (a, b) -> a + b;
		IntBinaryOperator type5 = (a, b) -> a - b;
		Supplier<Student> obj5 = () -> new Student();
		Supplier<List<Student>> obj6 = () -> List.of(new Student());
		Function<Student, String> obj7 = s -> s.getName();
		//通过上下文推导出s为Student
		Function<Student, Integer> obj8 = s -> s.getAge();

	}

	@FunctionalInterface
	interface Type0<O, I> {
		O test(I input);
	}

	@FunctionalInterface
	interface Type1 {
		boolean test(int a);
	}

	@FunctionalInterface
	interface IntTernaryOperator {
		int test(int a, int b, int c);
	}

	@FunctionalInterface
	interface Type3 {
		int test(int a, int b);
	}

	@FunctionalInterface
	interface Type4<T> {
		T test();
	}

}
